<?php 
$show_validator = true; 
include TMPL_PATH.'public/header.phtml';
?>
<style type='text/css'>
.pic {
    float: left;
    margin-right: 10px;
    text-align: center;
}
.pic img {
    border: 3px solid #EFEFED;
    cursor: pointer;
}
.pic img.current {
    border: 3px solid #FF6600;
}
</style>
<script type="text/javascript"> 
<!--
	$(function(){
		$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
		$("#description").formValidator({onshow:"请填写审核备注",onfocus:"请填写审核备注",oncorrect:"输入正确"}).inputValidator({min:2,onerror:"请填写审核备注"});
	})
//-->
</script>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
    		<a href='<?php echo U('comment/index');?>' ><em>评论列表</em></a><span>|</span>
        <a href='javascript:;' class="on" ><em>评论回复</em></a></div>
</div>
<div class="pad_10">
<div class="col-tab">
<!--	<ul class="tabBut cu-li">-->
<!--	<li id="tab_setting_1" class="on" onclick="SwapTab('setting','on','',2,1);">评论信息</li>-->
<!--	<li id="tab_setting_2" onclick="SwapTab('setting','on','',2,2);">反馈信息</li>-->
<!--	</ul>-->
	<form action="__SELF__" method="post" id="myform">
	<div id="div_setting_1" class="contentList pad-10">
		<table width="100%" class="table_form contentWrap">
		<tr>
		<td width="80">评论人名称</td> 
		<td><?php echo $comment['username'];?></td>
		</tr>
		<tr>
		<td>评论人邮箱</td>
		<td><?php echo $comment['email'];?></td>
		</tr>
		<tr>
		<td>评论<?php echo $commentName;?></td>
		<td><?php echo $comment['product_name'];?></td>
		</tr>
		<tr>
		<td>评论标题</td>
		<td><?php echo $comment['title'];?></td>
		</tr>
		<tr>
		<td>评论内容</td>
		<td><?php echo $comment['content'];?></td>
		</tr>
		<tr>
		<td>评论星级</td>
		<td><?php echo $comment['star'];?></td>
		</tr>
		<tr>
		<td>评论人IP</td>
		<td><?php echo $comment['ip'];?></td>
		</tr>
		<tr>
		<td>评论时间</td>
		<td><?php echo date('Y-m-d H:i:s', $comment['comment_time']);?></td>
		</tr>
		<tr>
		<td>评论状态</td>
		<td>
		
        <input type="radio" name="disabled" value="0" <?php echo !$comment['disabled'] ? 'checked' : '';?>/>隐藏 
        <input type="radio" name="disabled" value="1" <?php echo $comment['disabled'] ? 'checked' : '';?> />显示
        </td>
		</tr>
		<tr>
			<td></td>
			<td id="show_list">
			<?php 
				if($comment_photo):
					foreach ($comment_photo as $key=>$file):
			?>
						<span id="a<?php echo $file['fid'];?>" class="pic">
								<img name="img_name" <?php if(strpos($comment['img'],$file['img'])!==false){?>class="current"<?php }?> style="margin: 5px; opacity: 1;" src="<?php echo $file['thumb']?>" onclick="focus_img('<?php echo $file['img'];?>',this)"  <?php if($file['img'] == $product['img']):?>class="current"<?php endif;?> />
								<br>
								<!--<a id="<?php echo $file['fid'];?>" href="javascript:;" onclick="del_img(this.id)">删除</a>-->
							</span>
			<?php 
					endforeach;
				endif;
			?>
			</td>
		</tr>   
		</table>
	</div>
	<div id="div_setting_2" class="contentList pad-10">
	
	<?php if(isset($msgList) && $msgList):?>
	<table width="100%"  class="table_form">
	<?php 
//			$msgInfo = reset($msgList);
			foreach ($msgList as $msg):
	?>
		<tr>
	    <td width="80">回复</td>
	    <td class="y-bg"><?php echo $msg['content']?><br/>
					 回复时间： <?php echo date('Y-m-d H:i:s', $msg['comment_time']);?></td>
		</tr>
	<?php 
			endforeach;
	?>	
	  </table>
	  <div class="bk15"></div> 
	  <input name="" type="button" value="返回列表" class="button" onclick="javascript:location.href='<?php echo U('comment/index');?>';">
	  <?php else:?>
	  <div class="bk15"></div> 

	  <table width="100%"  class="table_form">
	  <tr>
	    <th width="120">审核备注：</th>
	    <td class="y-bg"><textarea name="content" id="description" cols="50" rows="5" style="width: 595px; height: 100px;"></textarea></td>
		</tr>
	  </table>
	  <div class="bk15"></div> 
	  <input name="dosubmit" type="submit" value="提交" class="button">
	 
	  <?php endif;?>
	</div>
    </form>
</div>
</div>
</body>
</html>
<script type="text/javascript">
function show_link(img)
{
	window.top.art.dialog({title:'图片链接', id:'link', iframe:'<?php echo U('product/public_show_photo_link_ajax');?>&img='+img,width:'600px',height:'200px'},function(){window.top.art.dialog({id:'link'}).close()});
}
function del_img(id)
{
	$('#del_photo_name').val($('#del_photo_name').val()+id+',')
	//删除数组元素.
	Array.prototype.remove=function(dx)
	{
	    if(isNaN(dx)||dx>this.length){return false;}
	    for(var i=0,n=0;i<this.length;i++)
	    {
	        if(this[i]!=this[dx])
	        {
	            this[n++]=this[i]
	        }
	    }
	    this.length-=1
	}
	//在数组中获取指定值的元素索引
	Array.prototype.getIndexByValue= function(value)
	{
	    var index = -1;
	    for (var i = 0; i < this.length; i++)
	    {
	        if (this[i] == value)
	        {
	            index = i;
	            break;
	        }
	    }
	    return index;
	}
	var photo_name = $('#photo_name').val();
	photo_name = photo_name.substring(0,photo_name.length-1);
	var arr = photo_name.split(',');
	var key = 0;
	for(var i=0;i<arr.length;i++){
		if(arr[i].indexOf(id)>-1){
			key = i;
		}
	}
	arr.remove(key);
	if(arr.length>0)
	{
		//如果没有全部删除则不为空
		$('#photo_name').val(arr.join(',')+',');
		$("#a"+id).remove();
		var focus_photo = $('#focus_photo').val();
		var is_curr = 0;//是否为选择图片
		$('#show_list > .pic > img').each(function(index){
			if($(this).hasClass('current')){
				is_curr=1;
			}
		});
		
		if(is_curr==1) return true;
		//重新选择第一个为默认图片
		curr_new_id = arr[0];

		var obj_curr_img = $("#a"+curr_new_id+'>img');
		obj_curr_img.addClass('current');
		$('#small_img').val(obj_curr_img.attr('src'));
		//$('#focus_photo').val(obj_curr_img.attr('original'));
		obj_curr_img.click();
	}else{
		//如果图片全部删除则值为空
		$('#photo_name').val("");
		$('#focus_photo').val("");
		$('#small_img').val("");
		$("#a"+id).remove();
	}
}
function focus_img(little,obj)
{
	window.open(little);
/*	$('#focus_photo').val(little);
	$("img[name='img_name']").removeClass('current');
	obj.className = 'current';*/
}
</script>